﻿using Newtonsoft.Json;
using SH.Common.CommonReturn;
using SH.Order.Domain.OrderClass;
using SH.Room.Application.IServices.IRoomNum;
using SH.Room.Application.IServices.IRoomState;
using SH.Room.Application.IServices.IStay;
using SH.Room.Domain.RoomClass;
using SH.Room.Infrastructure.IRepository;
using SH.Room.Infrastructure.IRepository.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SH.Room.Application.Services
{
    public class StayServices : BaseServices<StayInfo>, IStayServices
    {
        private readonly IStayRepository _repository;


        public StayServices(IStayRepository repository) : base(repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 统计房型个数
        /// </summary>
        /// <returns>受影响行数</returns>
        public async Task<RoomCountDto> GetRoomCountList()
        {
            var list = await _repository.GetListAsync();

            int AllCount = list.Count();

            int VacantCount = list.Where(x => x.Rsid == 1).Count();

            int UptownCount= list.Where(x => x.Rsid == 2).Count();

            int BookCount= list.Where(x => x.Rsid == 3).Count();

            int CheckCount= list.Where(x => x.MsId == 1).Count();

            int PigstyCount= list.Where(x => x.MsId == 2).Count();

            int MaintainCount = list.Where(x => x.MsId == 3).Count();

            return new RoomCountDto()
            {
                AllCount = AllCount,
                VacantCount = VacantCount,
                UptownCount = UptownCount,
                BookCount = BookCount,
                CheckCount = CheckCount,
                PigstyCount = PigstyCount,
                MaintainCount = MaintainCount
            };
            
        }
    }
}
